<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function loadIng(url){
        return new Promise((resolve,reject) => {
            let img = new Image();
            img.src = url;
            img.onload = () => {
                resolve(img);
            }
            img.onerror = () => {
                reject('图片加载失败')
            }
        })
    };

    let imgUrl = './1.jpg';
    loadIng(imgUrl).then(res => {
        document.documentElement.appendChild(res);
    }, erro => {
        console.log(erro);
    })
</script>
